﻿@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@if (false)
{
    <script src="../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>          
}


<script type="text/javascript">

    $(function () {
        if ('@ViewData["message"].ToString()' == "empty") {
            alert("非法用户绑定");
            $('#btnBind').hide();
            $('#btnLogin').hide();
        }
    });

    //绑定
    function userBind() {
        if (pd()) {
            $.ajax({
                type: 'POST',
                url: '/Index/UserBind',
                data: { logId: $.trim($("#userName").val()), password: $.trim($("#password").val()), uid: $('#hidUid').val() },
                success: function (result) {
                    if (result == "empty") {
                        alert("用户名或密码为空");
                    } else if (result == "ipAstrict") {
                        alert("ip受限制");
                    } else if (result == "banLogin") {
                        alert("该用户禁止登录");
                    } else if (result == "loginPast") {
                        alert("该用户已过期");
                    } else if (result == "no") {
                        alert("用户名或密码错误");
                    } else if (result == "ExistsSSOID") {
                        alert("该账户已经绑定，无法再次绑定");
                    } else if (result == "uidError") {
                        alert("单点登录用户错误(uid错误)");
                    } else if (result == "uidUpdError") {
                        alert("单点登录绑定保存失败");
                    } else if (result == "ok") {
                        alert("绑定成功");
                        window.location.href = "/Index/Index";
                    } else {
                        alert("参数错误");
                    }

                }

            });
        }
    }

    function userLogin() {
        if (pd()) {

            $.ajax({
                type: 'POST',
                url: '/Index/DirectLogin',
                data: { logId: $.trim($("#userName").val()), password: $.trim($("#password").val()) },
                success: function (result) {
                    if (result == "empty") {
                        alert("用户名或密码为空");
                    } else if (result == "ipAstrict") {
                        alert("ip受限制");
                    } else if (result == "banLogin") {
                        alert("该用户禁止登录");
                    } else if (result == "loginPast") {
                        alert("该用户已过期");
                    } else if (result == "no") {
                        alert("用户名或密码错误");
                    } else if (result == "ExistsSSOID") {
                        alert("该账户已经绑定，无法再次绑定");
                    } else if (result == "uidError") {
                        alert("单点登录用户错误(uid错误)");
                    } else if (result == "uidUpdError") {
                        alert("单点登录绑定保存失败");
                    } else if (result == "ok") {
                        alert("绑定成功");
                        window.location.href = "/Index/Index";
                    } else {
                        alert("参数错误");
                    }
                }
            });

        }
    }

    //登录
    function pd() {
        var bl = true;
        if ($.trim($("#userName").val()) == "") {
            alert("请填写用户名");
            bl = false;
        } else if ($.trim($("#password").val()) == "") {
            alert("请填写密码");
            bl = false;
        }
        return bl;
    }


</script>



<br /><br />
<div align="center">
 <table width="80%" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td align="center">
                                &nbsp;&nbsp;由于是第一次使用门户用户单点登录，请首先绑定用户。请在以下界面中输入您要绑定的用户名</td>
                        </tr>
                        <tr>
                            <td align="left">
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            </td>
                        </tr>
                    </table>
                    <table border="0" cellpadding="0" cellspacing="0" style="width: 60%">
                        <tr>
                            <td align="right" class="style1">
                                用户名：
                            </td>
                            <td align="left">
                                <input type="text" id="userName" />
                                </td>
                        </tr>
                        <tr>
                            <td align="right" class="style1">
                                密码：
                            </td>
                            <td align="left">
                                 <input type="password" id="password" />
                                </td>
                        </tr>
                        <tr>
                            <td align="right" class="style1">
                                &nbsp;
                            </td>
                            <td align="left">
                                <input type="button" class="btn" id="btnBind" value="绑定" onclick="userBind();" />
                                &nbsp;&nbsp;&nbsp;&nbsp;
                                <input type="button" class="btn" id="btnLogin" value="直接登录" style="width:60px" onclick="userLogin();"; />
                            </td>
                            
                        </tr>
                        <tr>
                        <td class="style1">
                        </td>
                        
                        </tr>
                    </table>
</div>
@Html.Hidden("hidUid", ViewData["uid"]);
<br />
<br />
<br />
<br />
<br />